<?php
/**
 *  ### Using the alias `i0' for the tree index table
 *
 *
 */
namespace Dclub\modules\Catalog;

class Action_SelectCatChildren
    extends \Yz\modules\Generic\Action_SelectList
{

    /**
     *  @var int ?
     */
    protected $catId;


    /************************************
     *         Public methods          *
     ************************************/


    /**
     *  @param int $fromNodeId
     *  @return this
     */
    public function setCatId( $catId )
    {
        debug();
        $this->catId = \Yz_Int::testPositive($catId);
        return $this;
    }


    /************************************
     *       Protected methods          *
     ************************************/


    /**
     *  Modified SELECT statement creator
     *
     */
    protected function buildSelect()
    {
        debug();
        $sql = parent::buildSelect()
            ->where("t0.parentId=:_catId")
            ->bind('_catId', $this->catId)
            ->orderBy("") // TODO do we need ordering at all?
            ->orderBy("t0.name") // TODO do we need ordering at all?
            ;
        return $sql;
    }


}
